﻿using FreeWorkflow.Repository;
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FreeWorkflow.DataAccess
{
    class ManageUsers : ManageEntity, IDataRepository<IdentityUser>
    {
        public object Add(IdentityUser dataModel)
        {
            context.Users.Add(dataModel);
            context.SaveChanges();
            return dataModel.Id;
        }

        public bool Update(IdentityUser dataModel)
        {
            context.SaveChanges();
            return true;
        }

        public bool Delete(IdentityUser dataModel)
        {
            context.Users.Remove(dataModel);
            context.SaveChanges();
            return true;
        }

        public IdentityUser GetById(object dataModelId)
        {
            return context.Users.Find(dataModelId);
        }

        public ICollection<IdentityUser> FindAll()
        {
            return context.Users.ToList<IdentityUser>();
        }
    }
}
